/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#ifndef OMEN_STORAGE_SERVER_H
#define OMEN_STORAGE_SERVER_H

#include "OmenConfig.h"
#include <IOmenStorageServer.h>
#include <IOmenArchiveReader.h>
#include <IOmenArchive.h>
#include <IOmenModelFileReader.h>
#include <IOmenImageFileReader.h>

#include <list>
#include <string>
#include <memory>
#include <stdexcept>

namespace Omen {

  /// <summary>Manages storage related stuff</summary>
  class OMEN_API StorageServer : public IStorageServer 
  {
  public: 

    StorageServer();
    virtual ~StorageServer();           /// <summary>Destroys the storage server</summary>
    
    virtual void addArchiveReader( Omen::IArchiveReader* pArchiveReader);        /// <summary>Allows plugins to add new archive readers</summary>
    virtual void addModelFileReader( Omen::IModelFileReader* pModelFileReader); /// <summary>Allows plugins to add new model file readers</summary>
    virtual void addImageFileReader( Omen::IImageFileReader* pImageFileReader); /// <summary>Allows plugins to add new image file readers</summary>
    
    /// <param name="filename">File a reader will be searched for</param>
    virtual IArchive* openArchive(const std::wstring& filename); /// <summry>Opens an archive by searching for a matching archive reader</summary>

    /// <param name="filename">File a reader will be searched for</param>
    virtual IModelFileReader* getModelFileReader(const std::wstring& filename); /// <summary>Returns an IModelFileReader which can read given file</summary>

    /// <param name="filename">File a reader will be searched for</param>
    virtual IImageFileReader* StorageServer::getImageFileReader(const std::wstring& filename); /// <summary>Returns an IImageFileReader which can read given file</summary>

    
  private:
    #pragma warning(disable:4251) // Disable warning about private member variable needs to have dll-interface to be used by clients of class 'this'
    /// <summary>A list of archive readers</summary>
     typedef std::list<IArchiveReader*> ArchiveFileReaders; /// <summary>Reads archive files like zips and rars</summary>
    ArchiveFileReaders m_archiveReaders;                        /// <summary>All available archive readers</summary>
    
    /// <summary>A list of model file readers</summary>
    typedef std::list<IModelFileReader*> ModelFileReaders;  /// <summary>Reads model files like omf, obj, 3ds...</summary>
    ModelFileReaders m_modelFileReaders;                    /// <summary>All available model file readers</summary>

    typedef std::list<IImageFileReader*> ImageFileReaders;  /// <summary>Reads model files like omf, obj, 3ds...</summary>
    ImageFileReaders m_imageFileReaders;                    /// <summary>All available model file readers</summary>
    #pragma warning(default:4251)
  };

  // ----------------------------------------------------------------------- //

} // namespace Omen

#endif // OMEN_STORAGE_SERVER_H
